<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>

</body>
<script>
	function axios(config){
		const {url,method="get"} = config;
		return new Promise(resolve=>{
			const xhr = new XMLHttpRequest();
			xhr.open(method,url);
			xhr.send();
			xhr.onload = function(){
				resolve({
					data:xhr.response
				})
			}
		})
	}
	axios.get = function(url){
		return this({url});
	}
	
	// axios({
	// 	url:"./19-封装.html"
	// }).then(value=>{
	// 	console.log(value.data);//  响应体
	// })
	axios.get("./19-封装.html").then(value=>{
		console.log(value.data);// 响应体
	})
</script>
</html>